(function() {
    if (!POOLS) {
        var POOLS = {};

        // 一定
        POOLS["d1"] = {};
        for (var i = 0; i < 5; i++) {

            var pools = [];
            for (var ii = 0; ii < 10; ii++) {
                var p = "XXXXX".split('');
                p[i] = ii + '';
                pools.push(p.join(''));
            }
            POOLS["d1"]['' + i] = pools

        }

        // 二定
        POOLS["d2"] = {};
        for (var i = 0; i < 5; i++) {
            for (var j = i + 1; j < 5; j++) {

                var pools = [];
                for (var ii = 0; ii < 10; ii++) {
                    for (var jj = 0; jj < 10; jj++) {
                        var p = "XXXXX".split('');
                        p[i] = ii + '';
                        p[j] = jj + '';
                        pools.push(p.join(''));
                    }
                }
                POOLS["d2"]['' + i + j] = pools;

            }
        }

        // 三定
        POOLS["d3"] = {};
        for (var i = 0; i < 5; i++) {
            for (var j = i + 1; j < 5; j++) {
                for (var k = j + 1; k < 5; k++) {

                    var pools = [];
                    for (var ii = 0; ii < 10; ii++) {
                        for (var jj = 0; jj < 10; jj++) {
                            for (var kk = 0; kk < 10; kk++) {
                                var p = "XXXXX".split('');
                                p[i] = ii + '';
                                p[j] = jj + '';
                                p[k] = kk + '';
                                pools.push(p.join(''));
                            }
                        }
                    }
                    POOLS["d3"]['' + i + j + k] = pools;

                }
            }
        }

        // 四定
        POOLS["d4"] = {};
        for (var i = 0; i < 5; i++) {
            for (var j = i + 1; j < 5; j++) {
                for (var k = j + 1; k < 5; k++) {
                    for (var m = k + 1; m < 5; m++) {

                        var pools = [];
                        for (var ii = 0; ii < 10; ii++) {
                            for (var jj = 0; jj < 10; jj++) {
                                for (var kk = 0; kk < 10; kk++) {
                                    for (var mm = 0; mm < 10; mm++) {
                                        var p = "XXXXX".split('');
                                        p[i] = ii + '';
                                        p[j] = jj + '';
                                        p[k] = kk + '';
                                        p[m] = mm + '';
                                        pools.push(p.join(''));
                                    }
                                }
                            }
                        }
                        POOLS["d4"]['' + i + j + k + m] = pools;

                    }
                }
            }
        }

        function count_unique() {
            var a = arguments;
            var b = [];
            for (var a1 of a) {
                var f = false;
                for (var b1 of b) {
                    if (b1 == a1) { f = true; break }
                }
                if (!f) { b.push(a1) }
            }
            return b.length;
        }

        // 二字、三字、四字
        POOLS["z2"] = {};
        POOLS["z3"] = {};
        POOLS["z4"] = {};
        for (var i = 0; i < 10; i++) {
            for (var j = i; j < 10; j++) {
                var c = '' + count_unique(i, j);
                if (!POOLS["z2"][c]) POOLS["z2"][c] = [];
                POOLS["z2"][c].push('' + i + j);
                for (var k = j; k < 10; k++) {
                    c = '' + count_unique(i, j, k);
                    if (!POOLS["z3"][c]) POOLS["z3"][c] = [];
                    POOLS["z3"][c].push('' + i + j + k);
                    for (var m = k; m < 10; m++) {
                        c = '' + count_unique(i, j, k, m);
                        if (!POOLS["z4"][c]) POOLS["z4"][c] = [];
                        POOLS["z4"][c].push('' + i + j + k + m);
                    }
                }
            }
        }

        localStorage["POOLS"] = JSON.stringify(POOLS);
    }
})();